package com.dd.shop4j.common.utils;

import org.springframework.web.servlet.ModelAndView;

/**
 * 消息提醒页面
 * 
 * @author Administrator
 * 
 */
public class Message {

	private MessageType type;	//页面类型
	private String gotoPage;	//跳转页面
	private String context;		//提醒内容
	private int second;			//显示秒数

	public Message() {
		second = 5;
	}
	
	public Message(MessageType type) {
		this();
		this.type = type;
	}

	public ModelAndView getView() {
		ModelAndView view = new ModelAndView(type.getPageUrl());
		view.addObject("message", this);
		return view;
	}

	public MessageType getType() {
		return type;
	}

	public void setType(MessageType type) {
		this.type = type;
	}

	public String getGotoPage() {
		return gotoPage;
	}
	

	public void setGotoPage(String gotoPage) {
		this.gotoPage = gotoPage;
	}

	
	public String getContext() {
		return context;
	}

	
	public void setContext(String context) {
		this.context = context;
	}

	
	public int getSecond() {
		return second;
	}

	
	public void setSecond(int second) {
		this.second = second;
	}

	/**
	 * 消息返回类型枚举类
	 * 
	 * @author Administrator
	 * 
	 */
	public static enum MessageType {

		CONSOLE_SUCCESS("/admin/message/success"), // 后台成功状态
		CONSOLE_FAILURE("/admin/message/failure"), // 后台失败状态
		WEBSITE_SUCCESS("/website/message/success"), // 前台成功状态
		WEBSITE_FAILURE("/website/message/failure"); // 前台失败状态

		private MessageType(String pageUrl) {
			this.pageUrl = pageUrl;
		}

		private String pageUrl;

		public String getPageUrl() {
			return pageUrl;
		}

	}
}
